# -*- mode:Makefile -*-
include ../Makefile.common
LANG=python
BASEDIR=..
DISTCLEANOBJ+=*.pyc setup.py build
CLEANOBJ+=$(DISTCLEANOBJ) $(MODULE).py
TARGET=_$(MODULE).so

do:$(TARGET)
$(TARGET): $(MODULE)_wrap.cpp setup.py
	python setup.py build
$(MODULE)_wrap.cpp: $(BASEDIR)/$(MODULE).i
	$(SWIG) -c++ -$(LANG) -o $@ $(BASEDIR)/$(MODULE).i
setup.py:
	echo "#!/usr/bin/env python" > $@
	echo "from distutils.core import setup,Extension,os" >> $@
	echo "import string" >> $@
	echo "setup(name = \"${MODULE}\"," >> $@
	echo "      version = '${VER}'," >> $@
	echo "      py_modules=[\"${MODULE}\"]," >> $@
	echo "      ext_modules = [" >> $@
	echo "        Extension(\"_${MODULE}\"," >> $@
	echo "                  [\"${MODULE}_wrap.cpp\",\"${BASEDIR}/${MODULE}.cpp\",\"${BASEDIR}/${MODULE}Plugin.cpp\"]," >> $@
	echo "                  include_dirs=[\"${BASEDIR}\", \"${BASEDIR}/ext\", \"${BOOST_INC}\"]," >> $@
	echo "                  library_dirs=[\"/bin\", \"${BOOST_LIB}\"]," >> $@
	echo "                  define_macros=[(\"BP_VERSION\", \"\\\"${VER}\\\"\"), (\"${OS}\", 1)]," >> $@
	echo "                  libraries=[\"stdc++\", \"boost_regex-gcc${GCC_VER}\"])" >> $@
	echo "        ])" >> $@
	echo "" >> $@
install: setup.py
	python setup.py install
